import org.ikastola.SecRole
import org.ikastola.SecUser
import org.ikastola.SecUserSecRole

class BootStrap {

    def init = { servletContext ->
			
			def adminRole = new SecRole(authority: 'ROLE_ADMIN').save(flush: true)
			def userRole = new SecRole(authority: 'ROLE_USER').save(flush: true)
			def adminUser = new SecUser(username: 'ikastola', enabled: true, password: 'ikas2013')	.save(flush: true)
			
			SecUserSecRole.create adminUser, adminRole, true
			
			assert SecUser.count() == 1
			assert SecRole.count() == 2
			assert SecUserSecRole.count() == 1
	}
		
    def destroy = {
    }
}
